package mysql

import "gorm.io/gorm"

type Order struct {
	gorm.Model
	OrderSn    string  `gorm:"char(36);NOT NULL;COMMENT:订单号"`
	UserId     int     `gorm:"int;NOT NULL;COMMENT:用户id"`
	Amount     float64 `gorm:"decimal(10, 2);NOT NULL;COMMENT:订单金额"`
	Status     int     `gorm:"tinyint(1);NOT NULL;DEFAULT 0;COMMENT:订单状态:0未支付,1已支付,2已取消,3已退款,4已完成"`
	Payment    int     `gorm:"tinyint(1);NOT NULL;COMMENT:支付方式:0微信,1支付宝,2银行卡,3余额"`
	GoodsTitle string  `gorm:"varchar(100);NOT NULL;COMMENT:商品标题"`
	GoodsPrice float64 `gorm:"decimal(10, 2);NOT NULL;COMMENT:商品价格"`
	GoodsId    int     `gorm:"int;NOT NULL;COMMENT:商品id"`
	GoodsCover string  `gorm:"varchar(200);NOT NULL;COMMENT:商品封面"`
}

func (o *Order) AddOrder() error {
	return DB.Create(&o).Error
}
